<?php

namespace app\common\service;
use app\index\model\Nav;
use app\index\model\Type;


class CommonService
{
    protected $out_data;
    
    // 构造函数
    public function __construct()
    {
        $this->out_data = ['errno'=>0,'errdesc'=>''];
    }

    public function set_err($errno,$errdesc) {
        $this->out_data['errno'] = $errno;
        $this->out_data['errdesc'] = $errdesc;
    }

    public function set_data($data) {
        $this->out_data['data'] = $data;
    }

    public function getAllNavData(){
        $navData = Nav::getAllData();
        $typeData = Type::getNavData();
        $nav = $type = [];
        foreach ($typeData as $key => $v) {
            $type[$v['nav_id']][] = $v;
        }
        foreach ($navData as $key => $v) {
            $nav[$key] = $v;
            $nav[$key]['type'] = $type[$v['nav_id']];
        }
        return $nav;
    }

}